package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {

    /**
     * @description: 新增菜品分类
     * @author: tanbobin
     * @date: 2024/5/29 18:12
     * @param:
     * @param category
     * @return:
     **/
    @AutoFill(OperationType.INSERT)
    @Insert("insert into category (type, name, sort, status, create_time, update_time, create_user, update_user)" +
            "    values (#{type}, #{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    void insert(Category category);

    /**
     * @description: 动态查询数据
     * @author: tanbobin
     * @date: 2024/5/29 18:12
     * @param:
//     * @param name
//     * @param type
     * @return:
     * @return java.util.List<com.sky.entity.Category>
     **/
//    @Select("select * from category")
//    List<Category> list();
    List<Category> list(String name, Integer type);

    /**
     * @description: 根据 id 查询分类是否为启用状态
     * @author: tanbobin
     * @date: 2024/5/31 18:02
     * @param:
     * @param id
     * @return:
     * @return java.lang.Long
     **/
//    Long queryById(Long id); 目前没有用上

    /**
     * @description: 根据id删除分类
     * @author: tanbobin
     * @date: 2024/6/1 15:18
     * @param:
     * @param id
     * @return:
     **/
    @Delete("delete from category where id = #{id}")
    void deleteById(Long id);

    /**
     * @description: 根据 id 查询分类数据
     * @author: tanbobin
     * @date: 2024/6/1 15:48
     * @param:
     * @param id
     * @return:
     * @return com.sky.entity.Category
     **/
    Category queryCategoryById(Long id);

    /**
     * @description: 修改分类数据
     * @author: tanbobin
     * @date: 2024/6/1 16:21
     * @param:
     * @param category
     * @return:
     **/
    @AutoFill(OperationType.UPDATE)
    void update(Category category);

    /**
     * @description: C端-查询分类
     * @author: tanbobin
     * @date: 2024/6/5 9:54
     * @param:
     * @param type
     * @return:
     * @return java.util.List<com.sky.entity.Category>
     **/
    List<Category> queryListType(Integer type);
}
